package com.pan.structual.adapter.adapt;

import com.pan.structual.adapter.color.MyColor;

import java.util.ArrayList;
import java.util.List;

public class RGBColorAdapter implements ColorAdapter {

    private MyColor myColor;

    public void setMyColor(MyColor myColor) {
        this.myColor = myColor;
    }

    @Override
    public List getColorList() {
        List<String> colorList = myColor.getColorList();
        List<int[]> resultList = new ArrayList<>();
        for (String s : colorList) {
            //rgb
            int[] color = new int[3];
            if (s.equals("red")){
                color[0] = 255;
                color[1] = 0;
                color[2] = 0;
            }else if (s.equals("green")){
                color[0] = 0;
                color[1] = 255;
                color[2] = 0;
            } else if (s.equals("blue")) {
                color[0] = 0;
                color[1] = 0;
                color[2] = 255;
            }else {
                throw new RuntimeException("未识别颜色");
            }
            resultList.add(color);
        }
        return resultList;
    }
}
